package generics;
import java.util.*;

public class AnimalDoctorGeneric2 {

	public void addAnimal(List<Animal> animals) {
		animals.add(new Dog());	//this is always legal, since Dog can be assigned to an Animal reference
	}
	
	public static void main(String[] args) {
		List<Animal> animals = new ArrayList<Animal>();
		animals.add(new Dog());
		animals.add(new Dog());
		AnimalDoctorGeneric2 doc = new AnimalDoctorGeneric2();
		doc.addAnimal(animals);	//OK, since animals matches the method arg
		
		for(Animal a : animals)
			System.out.println(a);
	}
	
}
